﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Ex03.VehicalsObjectModel
{
    public class Truck : Vehical, IFuleVehical
    {
        // Members
        private const float k_FuleTankCapacity = 150F;
        private const eFuleType k_FuleTankType = eFuleType.Soler;
        private float m_CurrentCargoLoad;
        private FuleEnergySystem m_FuleEnergySystem;

        // Ctor

        /// <summary>
        /// Creates a new fule based truck object
        /// </summary>
        /// <param name="i_LicenseNumber">The license number of the truck</param>
        /// <param name="i_CargoLoad">The cargo load of the truck</param>
        public Truck(string i_LicenseNumber, float i_CargoLoad)
            : base(i_LicenseNumber, new FuleEnergySystem(k_FuleTankType, k_FuleTankCapacity))
        {
            // Check the cargo load
            if (i_CargoLoad < 0)
            {
                throw new ArgumentException("Negative cargo load not allowed");
            }
            else
            {
                // Initialize the cargo and the wheels
                m_FuleEnergySystem = m_EnergySystem as FuleEnergySystem;
                m_CurrentCargoLoad = i_CargoLoad;
            }
        }

        // Properties
        protected override int k_NumOfWheels
        {
            get
            {
                return 8;
            }
        }

        protected override float k_DefaultWheelsPSI
        {
            get
            {
                return 24;
            }
        }

        /// <summary>
        /// Gets the current load of the truck's cargo in tons
        /// </summary>
        public float CurrentCargoLoad
        {
            get 
            { 
                return m_CurrentCargoLoad; 
            }
        }

        #region IFuleVehical Members

        /// <summary>
        /// Fules the system with a given amount of a certain fule type
        /// </summary>
        /// <param name="i_FuleType">The type of fule</param>
        /// <param name="i_AddedLitteres">The amount of fule to add</param>
        /// <exception cref="ArgumentException">When the fule type doesnt match the system's</exception>
        /// <exception cref="ValueOutOfRangeException">When the fule amount is negative or exceeds the capacity of the system</exception>
        public void Fule(eFuleType i_FuleType, float i_AddedLitters)
        {
            m_FuleEnergySystem.Fule(i_FuleType, i_AddedLitters);
        }

        /// <summary>
        /// Gets the current amount of fule litteres in the tank
        /// </summary>
        public float CurrentLitteres
        {
            get 
            {
                return m_FuleEnergySystem.CurrentFuleAmount;
            }
        }

        /// <summary>
        /// Gets the maximum litteres of fule the tank can hold
        /// </summary>
        public float MaximumLitteres
        {
            get 
            {
                return m_FuleEnergySystem.MaxFuleAmount;
            }
        }

        /// <summary>
        /// Gets the fule type of the vehical
        /// </summary>
        public eFuleType FuleType
        {
            get
            {
                return m_FuleEnergySystem.FuleType;
            }
        }

        #endregion
    }
}
